package com.djmw.mouse.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name = "t_bookmark")
@AssociationOverrides({
    // @AssociationOverride(name = "pk.id", joinColumns = @JoinColumn(name =
    // "c_id")),
    @AssociationOverride(name = "pk.position", joinColumns = @JoinColumn(name = "c_position_id")),
    @AssociationOverride(name = "pk.company", joinColumns = @JoinColumn(name = "c_company_id")),
    @AssociationOverride(name = "pk.memberUser", joinColumns = @JoinColumn(name = "c_member_user_id")),
    @AssociationOverride(name = "pk.type", joinColumns = @JoinColumn(name = "c_type"))
})
public class Bookmark extends IdEntity implements Serializable {
    private static final long serialVersionUID = -7479324941765920197L;
    private BookmarkId pk = new BookmarkId();
    private Date createDate;

    public Bookmark() {
    }

    // @EmbeddedId
    public BookmarkId getPk() {
        return pk;
    }
    public void setPk(BookmarkId pk) {
        this.pk = pk;
    }

    @Transient
    public Position getPosition() {
        return pk.getPosition();
    }
    public void setPosition(Position position) {
        pk.setPosition(position);
    }

    @Transient
    public Company getCompany() {
        return pk.getCompany();
    }
    public void setCompany(Company company) {
        pk.setCompany(company);
    }

    @Transient
    public MemberUser getMemberUser() {
        return pk.getMemberUser();
    }
    public void setMemberUser(MemberUser memberUser) {
        pk.setMemberUser(memberUser);
    }

    @Transient
    public int getType() {
        return pk.getType();
    }
    public void setType(int type) {
        pk.setType(type);
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "c_create_date")
    public Date getCreateDate() {
        return createDate;
    }
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    // @Override
    // @Transient
    // public int hashCode() {
    // return pk == null ? 0 : pk.hashCode();
    // }
}
